<!--# 
layout("/layout/default.html",{"menu":["struts","branch_admin"],"breadcrumbs":[{"name":"机构列表"}]}){ 
 #-->
<table class="tree_table table  table-hover general-table table-striped table-bordered" id="treeTable2">
	<thead>
		<tr>
			<th colspan="6">
				<div class="row">
					<div class="col-md-3 "></div>
					<div class="col-md-2 col-md-offset-7">
						<a href="${base}/branch/add" class="btn btn-info btn-sm"><i class="fa fa-plus-circle"></i> 添加机构</a>
					</div>
				</div>
			</th>
		</tr>
		<tr>
			<th>ID</th>
			<th>名称</th>
			<th>地址</th>
			<th>电话</th>
			<th>编码</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		<!--# for(branch in obj.data.pager.entities){ #-->
		<tr id="${branch.id!}" hasChild="${branch.hasSub!}">
			<td>${branch.id!}</td>
			<td>${branch.name!}</td>
			<td>${branch.address!}</td>
			<td>${branch.phone!}</td>
			<td>${branch.code!}</td>
			<td class="center">
				<div class="hidden-sm hidden-xs btn-group">
					<a class="btn btn-xs btn-info" href="${base}/branch/edit/${branch.id!}"> <i class="ace-icon fa fa-pencil bigger-120"></i> 编辑
					</a>
					<button class="btn btn-xs btn-danger btn-delete" data-url='/branch/delete' data-id='${branch.id!}'>
						<i class="ace-icon fa fa-trash-o bigger-120"></i> 删除
					</button>
				</div>
			</td>
		</tr>
		<!--#	} #-->
	</tbody>
	<tfoot>
		<!--# 
		if(obj.data.pager.entities.~size == 0){
		#-->
		<tr>
			<td colspan="6" class="null-pager">没有符合条件的数据</td>
		</tr>
		<!--#
		}else{
		#-->
		<tr>
			<td colspan="6">
				<div class="pull-right">${obj.data.pager.pagerBar!}</div>
			</td>
		</tr>
		<!--#
		}
	#-->
	</tfoot>
</table>
<script type="text/javascript" src="${base!}/resources/treeTable/jquery.treeTable.js"></script>
<script type="text/javascript">
<!--
	$(function() {
    var option = {
        expandLevel: 1,
        //theme : 'vsStyle',
        path: getRootPath() + '/resources/treeTable/',
        beforeExpand: function($treeTable, id) {
            if ($('.' + id, $treeTable).length) {
                return;
            }
            $.ajaxSetup({
                async: false
        });
            $.post(getRootPath() + '/branch/nodes', {
                id: id
            },
            function(result) {
                var html = '';
                if (result.length) {
                    $(result).each(function(i, item) {
                       	html += '<tr id="'
								+ item.id
								+ '" pId="'
								+ id
								+ '" '+(item.isParent > 0 ? "hasChild=\'true\'":'')+'><td>'
								+ item.id
								+ '</td><td>'
								+ item.name
								+ '</td><td>'
								+ item.sub_address
								+ '</td><td>'
								+ item.sub_phone
								+ '</td><td>'
								+ item.sub_code
								+ '</td><td class="center"><div class="hidden-sm hidden-xs btn-group">	<a class="btn btn-xs btn-success" href="${base}/branch/detail/'
								+ item.id +'"> <i class="ace-icon fa fa-check bigger-120"></i> 详情</a> <a class="btn btn-xs btn-info" href="${base}/branch/edit/'
								+ item.id +'"> <i class="ace-icon fa fa-pencil bigger-120"></i> 编辑	</a>	<button class="btn btn-xs btn-danger btn-delete" data-url="/branch/delete" data-id="'
								+ item.id +'"><i class="ace-icon fa fa-trash-o bigger-120"></i> 删除</button>	</div></td>	</tr>';
                        });
                     $treeTable.addChilds(html);
                } else {
                    showMessage("该机构没有下属机构!!");
                }
            },
            'json');
            $.ajaxSetup({
                async: true
        });
        },
        onSelect: function($treeTable, id) {
            window.console && console.log('onSelect:' + id);
        }
    };
    $('#treeTable2').treeTable(option);
});
//-->
</script>
<!--# } #-->